Sarue.Error('analytics.js', [
	['ANALYTICS_ACCOUNT', 'Analytics account UID was not defined']
]);

Addons.Google.Analytics = new Class({
	GOOGLEUSERACCOUNT: null,
	TRACKPAGEVIEW: null,
	
	construct: function(){
		_gaq = window['_gaq'] || [];

		this.ga_setAccount();
		this.ga_pageTrack();
		
		//Require analytics
		Sarue.Require(('https:'   == document.location.protocol ? 'https://ssl'   : 'http://www') + '.google-analytics.com/ga.js', false, false, true);
	},
	
	ga_setAccount: function(uid){
		if(!this.GOOGLEUSERACCOUNT)
			return Sarue.Error.handler('ANALYTICS_ACCOUNT', {line: 19});
		return _gaq.push(['_setAccount', uid || this.GOOGLEUSERACCOUNT]);
	},
	
	ga_pageTrack: function(str){
		return _gaq.push(['_trackPageview', str || this.TRACKPAGEVIEW]);
	},
	
	ga_eventTrack: function(category, action, opt_label, opt_value){
		return _gaq.push(['_trackEvent', category, action, opt_label, opt_value]);
	}
});
